﻿function addTooltip(ojb) {
    var it = document.getElementById("tempDiv");
    it.className = "toolTip";
    it.setAttribute("style", "left:" + (pos.x + 5).toString() + "px; top:" + (pos.y + 5).toString() + "px;");
    it.innerHTML = ojb.getAttribute("tt");
}
function hideTooltip() {
    var it = document.getElementById("tempDiv");
    it.className = "defaultTempDiv";
    it.innerHTML = "";
    it.removeAttribute("style");

}
function GetMouseXY(e) {
    var IE = document.all ? true : false
    if (!IE) document.captureEvents(Event.MOUSEMOVE)
    if (IE) {
        pos.x = event.clientX + document.body.scrollLeft;
        pos.y = event.clientY + document.body.scrollTop;
    }
    else {
        pos.x = e.pageX
        pos.y = e.pageY
    }
    if (pos.x < 0) { pos.x = 0 }
    if (pos.y < 0) { pos.y = 0 }
}
function changeValue(id1, id2) {
    if (id1.length != 0) {
        var target = document.getElementById(id2);
        target.innerHTML = id1.value;
    }
}
function changeHTML5() {
    var setNewType = false;
    if (!setNewType) {

        var a = document.getElementsByTagName('input');
        for (var i = 0; i < a.length; i++) {
            if (a[i].getAttribute('xtype')) {
                a[i].setAttribute('type', a[i].getAttribute('xtype'));
                a[i].removeAttribute('xtype');
            };

        }
    }
}
function convertHTML5(id) {
    if (id.getAttribute('xtype') != null) {
        var type = id.getAttribute('xtype');
        id.setAttribute('type', type);
        id.removeAttribute('xtype');

    }
}
function setCSS() {
    var tagTolltips = document.querySelectorAll('input[show="tooltip"]');
    for (var i = 0; i < tagTolltips.length; i++) {
        tagTolltips[i].setAttribute("onmousemove", "addTooltip(this)");
        tagTolltips[i].setAttribute("onmouseout", "hideTooltip()");
    }
    var tagTolltips = document.querySelectorAll('a[show="tooltip"]');
    for (var i = 0; i < tagTolltips.length; i++) {
        tagTolltips[i].setAttribute("onmousemove", "addTooltip(this)");
        tagTolltips[i].setAttribute("onmouseout", "hideTooltip()");
    }
}
function callEvent(id) {
    var target = document.getElementById(id);
    target.checked = true;
}
function changeValueAddPoint(it) {
    var varValue = it.parentNode;
    var element = varValue.getElementsByTagName('span');
    element[0].innerHTML = it.value;
}
function disableMe(it) {
    it.setAtribute("disabled", "disabled");
}
function changeChildStyle(it, tagname, classname) {
    var tempdiv = it.getElementsByTagName(tagname);
    for(var i = 0; i< tempdiv.length;i++)
    {
        tempdiv[i].setAttribute("class", classname);
    }
}
function changeDisplay(id, valueStyle) { 
    var ojb = document.getElementById(id);
    ojb.style.display = valueStyle;
}

function toggleShowOjb(id) {
    var ojb = document.getElementById(id);
    if(ojb.style.display == 'none')
        ojb.style.display = 'table';
    else
        ojb.style.display = 'none'
}
function setUrl(it, idImage, classname) {
    var image = document.getElementById(idImage);
    if (image.getAttribute('src').toString() != "") {
        image.setAttribute('src', it.value);
    }
    else
        image.setAttribute('src', 'https://lh5.googleusercontent.com/-eBDb-IaGF4U/TtElXMjnz9I/AAAAAAAAAJ8/3Cfqj7YTj-0/s800/noavatar.gif');
}